package com.lzs.Service.Impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lzs.DAO.DiseaseDAO;
import com.lzs.PO.Area;
import com.lzs.PO.Disease;
import com.lzs.PO.Page;
import com.lzs.Service.DiseaseService;

@Service
public class DiseaseServiceImpl implements DiseaseService{
     @Autowired
     DiseaseDAO diseaseDAO;
	
	public Page<Disease> findDiseasePagelist(String keyword, Integer pageSize, Integer pageNum) {
		
		List<Disease> arealist = this.diseaseDAO.findDiseaseList(keyword);

		int totalRecord = arealist.size();

		Page<Disease> page = new Page<Disease>(pageNum, pageSize, totalRecord);

		int startIndex = page.getStartIndex();

		page.setList(diseaseDAO.findDiseasePagelist(keyword, startIndex, pageSize));
		
		return page;
	}

	@Override
	public Boolean countDiseaseById(String disease_id) {
		
		long count = this.diseaseDAO.countDiseaseById(disease_id);
		
		return count==0;
	}

	@Override
	public void addDisease(Map<String, Object> map) {
		
		this.diseaseDAO.addDisease(map);
		
	}

	@Override
	public Disease findDiseaseById(String disease_id) {
		
		Disease disease = this.diseaseDAO.findDiseaseById(disease_id);
		
		return disease;
	}

	@Override
	public void updateDisease(Map<String, Object> map) {
		
		this.diseaseDAO.updateDisease(map);
		
	}

	@Override
	public void deleteDisease(String disease_id) {

       this.diseaseDAO.deleteDisease(disease_id);
		
	}

}
